/**
 * 组织架构api
 */

import request from '@/utils/request'

/**
 * @description 获取公司组织架构
 * @returns Promise
 */
export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'get'
  })
}
/**
 * @description 获取负责人简单列表
 * @returns
 */
export function getEmployeeSimple() {
  return request({
    url: '/sys/user/simple',
    method: 'get'
  })
}

/**
 * @description 添加子部门
 * @param {*} data
 * @returns
 */
export function addDepartment(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * @description 通过父级id获取部门详情信息
 * @param {*} id
 * @returns
 */
export function getDetails(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'get'
  })
}

/**
 * @description 通过父级id编辑部门
 * @param {*} id
 * @returns
 */
export function editDepartment(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * @description 删除部门
 * @param {*} id
 * @returns
 */
export function delDepartment(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}
